<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>dandian2-NewFile</title>
</head>
<body>
	<a href="/Test_DanDian_2/LoginServlet">LoginServlet</a>

	<button onclick="Setcookie('user-name-sss','value-sssss');" >点击设置cookie</button>
</body>

	<script type="text/javascript">
		function Setcookie (name, value) { 
		    //设置名称为name,值为value的Cookie
		    var expdate = new Date();   //初始化时间
		    expdate.setTime(expdate.getTime() + 30 * 60 * 1000);   //时间
		    document.cookie = name+"="+value+";expires="+expdate.toGMTString()+";path=/";
		    console.log(document.cookie)
		    
		   //即document.cookie= name+"="+value+";path=/";   时间可以不要，但路径(path)必须要填写，因为JS的默认路径是当前页，如果不填，此cookie只在当前页面生效！~
		}
	</script>
</html>